package com.j2eefast.flowable.erp.service;


import com.j2eefast.flowable.erp.entity.bpmErpPersonLoanEntity;
import com.j2eefast.flowable.erp.mapper.bpmErpPersonLoanMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * ERP人事借款申请Service接口
 * @author: yhli
 * @date 2020-07-21 17:45
 */
@Service
public class bpmErpPersonLoanService extends ServiceImpl<bpmErpPersonLoanMapper,bpmErpPersonLoanEntity> {

	@Resource
	private bpmErpPersonLoanMapper bpmErpPersonLoanMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmErpPersonLoanEntity> queryWrapper = new QueryWrapper<bpmErpPersonLoanEntity>();
           String serialNumber = (String) params.get("serialNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(serialNumber), "serial_number", serialNumber);
                                  String moneyMoney = (String) params.get("moneyMoney");
         queryWrapper.eq(ToolUtil.isNotEmpty(moneyMoney), "money_money", moneyMoney);
                                     String managerApproval = (String) params.get("managerApproval");
         queryWrapper.eq(ToolUtil.isNotEmpty(managerApproval), "manager_approval", managerApproval);
                String payPaymentdate = (String) params.get("payPaymentdate");
         queryWrapper.eq(ToolUtil.isNotEmpty(payPaymentdate), "pay_paymentdate", payPaymentdate);
          String payPreferencePaymethod = (String) params.get("payPreferencePaymethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(payPreferencePaymethod), "pay_preference_paymethod", payPreferencePaymethod);
             String payReceiptNumber = (String) params.get("payReceiptNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(payReceiptNumber), "pay_receipt_number", payReceiptNumber);
          String payProof = (String) params.get("payProof");
         queryWrapper.eq(ToolUtil.isNotEmpty(payProof), "pay_proof", payProof);
          String payRecipientName = (String) params.get("payRecipientName");
        queryWrapper.like(ToolUtil.isNotEmpty(payRecipientName), "pay_recipient_name", payRecipientName);
          String payRecipientAddress = (String) params.get("payRecipientAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(payRecipientAddress), "pay_recipient_address", payRecipientAddress);
          String payRecipientPhone = (String) params.get("payRecipientPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(payRecipientPhone), "pay_recipient_phone", payRecipientPhone);
          String payAccountNumber = (String) params.get("payAccountNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(payAccountNumber), "pay_account_number", payAccountNumber);
          String payRoutingNumber = (String) params.get("payRoutingNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(payRoutingNumber), "pay_routing_number", payRoutingNumber);
          String payBankAddress = (String) params.get("payBankAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(payBankAddress), "pay_bank_address", payBankAddress);
             String payBankName = (String) params.get("payBankName");
        queryWrapper.like(ToolUtil.isNotEmpty(payBankName), "pay_bank_name", payBankName);
          String payBankAccount = (String) params.get("payBankAccount");
         queryWrapper.eq(ToolUtil.isNotEmpty(payBankAccount), "pay_bank_account", payBankAccount);
          String payAccountName = (String) params.get("payAccountName");
        queryWrapper.like(ToolUtil.isNotEmpty(payAccountName), "pay_account_name", payAccountName);
             String cashierDate = (String) params.get("cashierDate");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierDate), "cashier_date", cashierDate);
          String cashierReceiptNumber = (String) params.get("cashierReceiptNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierReceiptNumber), "cashier_receipt_number", cashierReceiptNumber);
          String cashierProof = (String) params.get("cashierProof");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierProof), "cashier_proof", cashierProof);
           		Page<bpmErpPersonLoanEntity> page = bpmErpPersonLoanMapper.selectPage(new Query<bpmErpPersonLoanEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmErpPersonLoanEntity bpmErpPersonLoanEntity) {
		Page<bpmErpPersonLoanEntity> page = bpmErpPersonLoanMapper.findPage(new Query<bpmErpPersonLoanEntity>(params).getPage(), bpmErpPersonLoanEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmErpPersonLoanByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmErpPersonLoanById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmErpPersonLoan(bpmErpPersonLoanEntity bpmErpPersonLoan){
        return save(bpmErpPersonLoan);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmErpPersonLoanById(bpmErpPersonLoanEntity bpmErpPersonLoan) {
		return updateById(bpmErpPersonLoan);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmErpPersonLoanEntity getbpmErpPersonLoanById(String id){
		return getById(id);
	}
}
